﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace EmProductCenter.pxjd
{
    public partial class courseinfo : System.Web.UI.Page
    {
        BLL.ePioneer_CourseInfo bllEPCI = new BLL.ePioneer_CourseInfo();
        public string title = "暂无数据";
        public string solutionType = "暂无数据";
        public string lecturer = "暂无数据";
        public string courseStartDate = "2011-01-01";
        public string startTime = "08:00";
        public string mainContent = "暂无数据";
        public string briefInfo = "暂无数据";
        public int count = 0;
        public string imageR = "<p class='place_count'>名额已满</p>";
        public string loginName = "";
        public string imageT = "<img src='../image/js_1.jpg' width='227' height='270' alt='' />";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int id = 0;
                if (Request["id"] != null && Request["id"] != "")
                    id = Convert.ToInt32(Request["id"]);
                DataRow[] drs = bllEPCI.GetCourseInfo(id);
                if (drs.Count() > 0)
                {
                    Title = drs[0]["Title"].ToString();
                    title = drs[0]["Title"].ToString();
                    solutionType = drs[0]["SolutionType"].ToString();
                    lecturer = drs[0]["Lecturer"].ToString();
                    if (drs[0]["CourseStartDate"] != null && drs[0]["CourseStartDate"].ToString() != "")
                        courseStartDate = Convert.ToDateTime(drs[0]["CourseStartDate"]).ToString("yyyy-MM-dd");
                    startTime = drs[0]["StartTime"].ToString();
                    mainContent = drs[0]["MainContent"].ToString().Replace("\r\n", "<br/>");
                    briefInfo = drs[0]["BriefInfo"].ToString().Replace("\r\n", "<br/>");
                    if (drs[0]["IReservation"] != null && drs[0]["IReservation"].ToString() != "")
                        count = Convert.ToInt32(drs[0]["IReservation"]) - Convert.ToInt32(drs[0]["CountRes"]);
                    if (count > 0)
                        imageR = "<p class='place_count'>预约名额还有 <span class='red'>" + count + "</span> 个</p><a href='javascript:void(0);'><img src='../image/btn_order.gif' width='192' height='56' alt='' onclick='Reservation("+id+");' /></a>";
                    if (drs[0]["PicUrl"] != null && drs[0]["PicUrl"].ToString() != "")
                        imageT = "<img src='" + drs[0]["PicUrl"] + "' width='227' height='270' alt='' />";
                    isLine.Value = drs[0]["IsLine"].ToString();
                }
                if (Session["LoginName"] != null)
                    hid_userName.Value = Session["LoginName"].ToString();
            }
        }
    }
}